import service from "../utils/request";

const now = new Date().getTime();

export const getRoleListAll = (params: any) => {
    return service.get("/nttboot/sys/role/list", {params});
};

// 添加角色
export const addRole = (data: any) => {
    return service.post("/nttboot/sys/role/add", data);
};

// 编辑角色
export const editRole = (data: any) => {
    return service.post("/nttboot/sys/role/edit", data);
};

//删除角色
export const deleteRole = (params: any) => {
    return service.delete("/nttboot/sys/role/delete", {params});
}

// 获取角色用户
export const getRoleUsers = (params: any) => {
    return service.get("/nttboot/sys/user/userRoleList", {params});
}

//取消关联
export const deleteUserRole = (params: any) => {
    return service.delete("/nttboot/sys/user/deleteUserRole", {params});
}

// 添加用户到角色
export const addSysUserRole = (data: any) => {
    return service.post("/nttboot/sys/user/addSysUserRole", data);
};

//授权
export const saveRolePermission = (data: any) => {
    return service.post("/nttboot/sys/permission/saveRolePermission", data);
};

//获取角色权限
export const getRolePermission = (params: any) => {
    return service.get(`/nttboot/sys/permission/queryRolePermission?_t=${now}`, {params});
};

//获取权限树
export const getPermissionTree = () => {
    return service.get(`/nttboot/sys/role/queryTreeList?_t=${now}`);
};